package oa.base.util;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.UUID;

public class GenericsUtils
{
	/**
	 * @param clazz
	 * @return
	 */
	public static Class<?> getGenericClass(Class<?> clazz) {
		Type genType = clazz.getGenericSuperclass();

		if (genType instanceof ParameterizedType) {
			Type[] params = ((ParameterizedType) genType)
					.getActualTypeArguments();

			if ((params != null) && (params.length == 1)) {
				return (Class<?>) params[0];
			}
		}

		return null;
	}
	
	/**
	 * UUID  seq
	 * @param name 后缀
	 * @return
	 */
	public static String nextId(String name){
		return UUID.randomUUID().toString()+name;
	}
	
	public static final String nextRandId(){
		String uuid = UUID.randomUUID().toString().replace("-", "");
		StringBuilder sb = new StringBuilder();
		sb.append(DateUtil.getCurrentTime(DateUtil.YEAR_MONTH_DAY_LH));
		sb.append(uuid.toUpperCase());
		return sb.toString();
	}
	
	public static void main(String[] args) {
		System.out.println(FileUtils.substractSuffix("dsadas.dsd.doc"));
	}
}